package com.hspedu.seckill.controller;

import com.hspedu.seckill.pojo.User;
import com.hspedu.seckill.service.UserService;
import com.hspedu.seckill.vo.RespBean;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;


    //@RequestMapping("/info")
    //public RespBean info(User user, String address) {
    //    System.out.println("address -->" + address);
    //    return RespBean.success(user);
    //}

    @RequestMapping("/info")
    public RespBean info(User user) {
        return RespBean.success(user);
    }

    //处理更新密码
    @RequestMapping("/updpwd")
    @ResponseBody
    public RespBean updatePassword(@CookieValue("userTicket") String userTicket,
                                   String password,
                                   HttpServletRequest request,
                                   HttpServletResponse response){
        return userService.updatePassword(userTicket,password,request,response);
    }

}
